/**
 * 初始化或获取MyParam集合常量
 * @author 董一华
 * @since 1.00
 * @version 1.00 
 * 
 * 修订列表： v1.00 2009-10-24 
 * 			修订人：董一华 
 * 			修订内容：初始版本 
 */

package com.zjht.gmcc.bean.util;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.zjht.gmcc.bean.model.BOSS_Depot;
import com.zjht.gmcc.bean.model.CM_FeedBackCode;
import com.zjht.gmcc.bean.model.IMEILog;

public class MyParamUtil {

	/**
	 * 根据地市ID获取地市中文名称
	 * @author dyh 2009-10-24
	 * @param strAreaID
	 * @return 地市名称
	 */
	public static String getAreaName(String strAreaID) {
		return getAreaName(strAreaID, false);
	}

	/**
	 * 根据地市ID获取地市中文名称
	 * @author dyh 2010-03-30
	 * @param intAreaID  
	 * @return 地市名称
	 */
	public static String getAreaName(int intAreaID) {
		return getAreaName(intAreaID + "");
	}

	/**
	 * 根据地市ID获取地市中文名称
	 * @author dyh 2010-03-30
	 * @param intAreaID
	 * @param GMCC 是否显示浙江移动
	 * @return 地市名称
	 */
	public static String getAreaName(int intAreaID, boolean GMCC) {
		return getAreaName(intAreaID + "", GMCC);
	}

	/**
	 * 根据地市ID获取地市中文名称
	 * @author dyh 2009-10-24
	 * @param strAreaID
	 * @param GMCC 是否显示浙江移动
	 * @return 地市名称
	 */
	public static String getAreaName(String strAreaID, boolean GMCC) {
		String areaname = "";
		try {
			if (!MyFormat.isStrNull(strAreaID)) {
				if (MyConstant.AREAID_GMCC == MyFormat.formatInt(strAreaID)) {
					if (GMCC) {
						areaname = "浙江移动";
					} else {
						areaname = "浙江省";
					}
				} else {
					if (MyParam.hAreaIDToAreaName == null || MyParam.hAreaIDToAreaName.size() == 0) {
						InitParam.initArea();
					}
					areaname = MyParam.hAreaIDToAreaName.get(strAreaID);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
		return MyFormat.formatStr(areaname);
	}

	/**
	 * 根据地市ID获取地市编码
	 * @author dyh 2009-10-24
	 * @param intAreaID
	 * @return 地市名称
	 */
	public static String getAreaCode(int intAreaID) {
		String areacode = "";
		try {
			if (MyConstant.AREAID_GMCC == intAreaID) {
				areacode = MyConstant.AREACODE_GD;
			} else if (MyFormat.checkAreaID(intAreaID)) {
				if (MyParam.AreaCode == null || MyParam.AreaCode.size() == 0) {
					InitParam.initArea();
				}
				areacode = MyParam.AreaCode.get(intAreaID - 1);
			}
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		return MyFormat.formatStr(areacode);
	}

	/**
	 * 根据地市ID获取地市编码
	 * @author dyh 2010-06-05
	 * @param intAreaID
	 * @return 地市名称
	 */
	public static String getAreaCode(String areaID) {
		try {
			if (areaID == null)
				return null;
			return getAreaCode(Integer.parseInt(areaID));
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	/**
	 * 输入地市ID，获取区域ID
	 * @author dyh 2011-08-06
	 * @param areaid 地市ID
	 * @return 区域ID
	 */
	public static int getZoneID(int areaid) {
		int zoneid = MyConstant.INT_NULL;
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String strSQL = "SELECT parentid FROM AREA WHERE areaid=?";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setInt(1, areaid);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				zoneid = rs.getInt(1);
			}
			rs.close();
			rs = null;
		} catch (Exception e) {
			e.printStackTrace();
			return MyConstant.INT_NULL;
		} finally {
			MyJDBC.close(myJDBC);
		}
		return zoneid;
	}

	/**
	 * 输入区域ID，获取区域名称
	 * @author dyh 2011-08-06
	 * @param zoneid 区域ID
	 * @return 区域名称
	 */
	public static String getZoneName(int zoneid) {
		String zonename = "";
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String strSQL = "SELECT areaname FROM AREA WHERE areaid=?";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setInt(1, zoneid);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				zonename = rs.getString(1);
			}
			rs.close();
			rs = null;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyJDBC.close(myJDBC);
		}
		return MyFormat.formatStr(zonename);
	}

	/**
	 * 根据部门ID获取部门中文名
	 * @author dyh 2009-11-15
	 * @param strDeptID
	 * @return 部门名称
	 */
	public static String getDeptName(String strDeptID) {
		String deptname = "";
		try {
			if (!MyFormat.isStrNull(strDeptID)) {
				if (MyParam.hDeptIDToDeptName == null || MyParam.hDeptIDToDeptName.size() == 0) {
					InitParam.initDeptName();
				}
				deptname = MyParam.hDeptIDToDeptName.get(strDeptID);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return MyFormat.formatStr(deptname);
	}

	/**
	 * 根据部门ID获取部门中文名
	 * @author dyh 2009-11-15
	 * @param strDeptID
	 * @return 部门名称
	 */
	public static String getDeptName(int strDeptID) {
		return getDeptName(strDeptID + "");
	}

	/**
	 * 获取组织简称
	 * @author dyh 2009-10-24
	 * @param strOrgaCode
	 * @return 组织简称
	 */
	public static String getOrgaShortName(String strOrgaCode) {
		String shortname = "";
		if (!MyFormat.isStrNull(strOrgaCode)) {
			shortname = MyParam.hOrgaCodeToShortName.get(strOrgaCode);
		}
		return MyFormat.formatStr(shortname);
	}

	/**
	 * 获取组织简称
	 * @author dyh 2010-12-30
	 * @param orgid
	 * @return 组织简称
	 */
	public static String getOrgaShortName(int orgid) {
		String shortname = "";
		if (orgid > 0) {
			shortname = MyParam.hOrgIDToShortName.get(Integer.valueOf(orgid));
		}
		return MyFormat.formatStr(shortname);
	}

	/**
	 * 获取组织编码
	 * @author dyh 2010-12-30
	 * @param orgid
	 * @return 组织编码
	 */
	public static String getOrgaCode(int orgid) {
		String orgacode = "";
		if (orgid > 0) {
			orgacode = MyParam.hOrgIDToCode.get(Integer.valueOf(orgid));
		}
		return MyFormat.formatStr(orgacode);
	}

	/**
	 * 输入组织编码，获取该组织ID
	 * @author dyh 2011-01-10
	 * @param orgacode 组织编码
	 * @return 组织ID
	 */
	public static int getOrgID(String orgacode) {
		int orgid = MyConstant.INT_NULL;
		if (MyFormat.isStrNull(orgacode))
			return orgid;
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String strSQL = "SELECT orgid FROM ORGANIZA WHERE orgacode=?";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setString(1, orgacode);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				orgid = rs.getInt(1);
			}
			rs.close();
			rs = null;
			return orgid;
		} catch (Exception e) {
			e.printStackTrace();
			return MyConstant.INT_NULL;
		} finally {
			MyJDBC.close(myJDBC);
		}
	}

	/**
	 * 获取组织类型
	 * @author dyh 2009-10-24
	 * @param strOrgaCode
	 * @return 组织类型
	 */
	public static int getOrgaTypeID(String strOrgaCode) {
		int result = MyConstant.INT_NULL;
		if (MyFormat.isStrNull(strOrgaCode))
			return result; 
		MyJDBC myJDBC = null;
		try { 
			myJDBC = new MyJDBC();
			String strSQL = "SELECT orgatypeid FROM ORGANIZA WHERE orgacode=?";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setString(1, strOrgaCode);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				result = rs.getInt(1);
			}
			rs.close();
			rs = null;
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return MyConstant.INT_NULL;
		} finally {
			MyJDBC.close(myJDBC);
		}
	}

	/**
	 * 输入组织编码，获取该组织的渠道类型
	 * @author dyh 2009-12-15
	 * @param orgacode 组织编码
	 * @return 渠道类型，如果为null，表示无法找到该组织
	 */
	public static int getOrgaTypeID(int orgid) {
		int result = MyConstant.INT_NULL;
		if (orgid <= 0)
			return result;
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String strSQL = "SELECT orgatypeid FROM ORGANIZA WHERE orgid=?";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setInt(1, orgid);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				result = rs.getInt(1);
			}
			rs.close();
			rs = null;
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return MyConstant.INT_NULL;
		} finally {
			MyJDBC.close(myJDBC);
		}
	}

	/**
	 * 获取组织地市号
	 * @author dyh 2009-10-24
	 * @param strOrgaCode
	 * @return 组织地市号
	 */
	public static int getOrgaAreaID(String strOrgaCode) {
		int intReceiverAreaID = -1;
		try {
			if (strOrgaCode == null || strOrgaCode.length() == 0)
				return -1;
			if (MyParam.hOrgaCodeToAreaID == null || MyParam.hOrgaCodeToAreaID.size() == 0) {
				InitParam.initOrgaInfo();
			}
			String receiverAreaID = MyParam.hOrgaCodeToAreaID.get(strOrgaCode);
			if (receiverAreaID == null)
				return -1;

			try {
				intReceiverAreaID = Integer.parseInt(receiverAreaID);
			} catch (Exception ex2) {

			}
			if (intReceiverAreaID <= 0 || intReceiverAreaID >= MyConstant.AREA_MAX)
				return -1;
		} catch (Exception x) {
		}
		return intReceiverAreaID;
	}

	/**
	 * 获取父组织编号
	 * @author dyh 2009-10-24
	 * @param strOrgaCode
	 * @return 父组织编号
	 */
	public static String getParentOrgaCode(String strOrgaCode) {
		if (strOrgaCode == null || strOrgaCode.length() == 0)
			return null;
		return MyParam.hOrgaCodeToParentOrgaCode.get(strOrgaCode);
	}

	/**
	 * 根据补货单或退货单号取得市平台组织编码
	 * @author dyh 2009-10-24
	 * @param strCode 补货单号或退货单号
	 * @param CodeType 0：补货单，1：退货单
	 * @return 市平台组织编码
	 */
	public static String getCityProvider(String strCode, int CodeType) {
		if (strCode == null || strCode.length() == 0 || CodeType > 1 || CodeType < 0)
			return null;
		String strCityProvider = null;
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String strSQL = "";
			if (CodeType == 0)
				strSQL = "SELECT ReqOrgaCode FROM REQUIRE WHERE ReqCode=?";
			else
				strSQL = "SELECT POrgaCode FROM RETURNBUSI WHERE ReturnCode=?";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setString(1, strCode);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				strCityProvider = rs.getString(1);
			}
			return strCityProvider;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			MyJDBC.close(myJDBC);
		}
	}

	/**
	 * 获取补货信息(req内容:reqtype`reqorgacode`objorgacode)
	 * @author dyh 2009-10-24
	 * @param strReqCode
	 * @return 补货信息
	 */


	/**
	 * 更新补货信息
	 * @author dyh 2009-10-24
	 * @param strReqCode
	 * @param strReqType
	 */

	/**
	 * 移除补货信息
	 * @author dyh 2009-10-24
	 * @param strReqCode
	 */

	/**
	 * 获取退货信息(ReturnInfo内容：hallorgacode`productname`returnquantity`cityproviderorgacode)
	 * @author dyh 2009-10-24
	 * @param strReturnCode
	 * @return 退货信
	 */


	/**
	 * 更新退货信息
	 * @author dyh 2009-10-24
	 * @param strReturnCode
	 * @param strReturnInfo
	 */
	

	/**
	 * 通过menuid获取menuname
	 * @author dyh 2009-11-07
	 * @param menuid
	 * @return menuname
	 */
	public static String getMenuName(String menuid) {
		if (menuid == null || menuid.length() == 0)
			return null;
		String menu = MyParam.hOperMenu.get(menuid);
		if (menu != null) {
			return menu.substring(0, menu.indexOf("`"));
		}
		return null;
	}

	/**
	 * 通过menuid获取父menuid
	 * @author dyh 2009-11-07
	 * @param menuid
	 * @return parentmenuid
	 */
	public static String getParentMenuID(String menuid) {
		if (menuid == null || menuid.length() == 0)
			return null;
		String menu = MyParam.hOperMenu.get(menuid);
		if (menu != null) {
			String menuinfo[] = menu.split("`");
			return menuinfo[1];
		}
		return null;
	}

	/**
	 * 单条IMEI插入IMEILog表，作为IMEI操作日志(传入参数均不能为null或length=0)
	 * @author dyh 2009-12-09
	 * @param conn 将调用方法的连接传入
	 * @param IMEI
	 * @param orgacode 处理组织
	 * @param opercode 处理人
	 * @param dealid 处理单据ID
	 * @param dealpaper 处理单据号
	 * @param dealtype 处理类型(MyConstant.DEALTYPE_XXX)
	 * @param price 处理时IMEI价格
	 * @param frompaper 处理依据
	 * @param objorgacode 接收组织
	 * @return true表示日志插入成功，false表示失败
	 */
	private static boolean insertIMEILog(Connection conn, String IMEI, String orgacode, String opercode, int dealid, String dealpaper,
			String dealtype, double price, String frompaper, String objorgacode) throws Exception {
		boolean isOK = false;
		if (!JDBCUtil.isConnected(conn)) {
			return isOK;
		}
		if (IMEI == null || IMEI.length() == 0 || orgacode == null || orgacode.length() == 0 || opercode == null || opercode.length() == 0
				|| dealpaper == null || dealpaper.length() == 0 || dealtype == null || dealtype.length() == 0)
			return isOK;

		String s_sql = "INSERT INTO IMEILOG (IMEI,OrgaCode,OperCode,DealDate,DealID,DealPaper,DealType,Price,FromPaper,ObjOrgaCode) VALUES (?,?,?,SYSDATE,?,?,?,?,?,?)";
		PreparedStatement ps = conn.prepareStatement(s_sql);
		ps.setString(1, IMEI);
		ps.setString(2, orgacode);
		ps.setString(3, opercode);
		ps.setInt(4, dealid);
		ps.setString(5, dealpaper);
		ps.setString(6, dealtype);
		ps.setDouble(7, price);
		ps.setString(8, frompaper);
		ps.setString(9, objorgacode);
		int i_flag = ps.executeUpdate();
		ps.close();
		if (i_flag == 1)
			isOK = true;
		return isOK;
	}

	/**
	 * 多条IMEI插入IMEILog表，作为IMEI操作日志(传入参数均不能为null或length=0)
	 * @author dyh 2009-12-09
	 * @param conn 将调用方法的连接传入
	 * @param imeiloglist List<IMEILog>
	 * @return true表示日志插入成功，false表示失败
	 */
	public static boolean insertIMEILog(Connection conn, List<IMEILog> imeiloglist) throws Exception {
		if (imeiloglist == null || imeiloglist.size() == 0)
			return false;

		// 检测imeiloglist里每一条记录字段的合法性
		String IMEI = null;
		String orgacode = null;
		String opercode = null;
		int dealid = 0;
		String dealpaper = null;
		String dealtype = null;
		double price = 0;
		String frompaper;// 处理依据
		String objorgacode;// 接收组织

		// 检测imeiloglist数据的合法性
		for (IMEILog imeilog : imeiloglist) {
			if (imeilog == null)
				return false;
			IMEI = imeilog.getIMEI();
			orgacode = imeilog.getOrgacode();
			opercode = imeilog.getOpercode();
			dealid = imeilog.getDealid();
			dealpaper = imeilog.getDealpaper();
			dealtype = imeilog.getDealtype();
			price = imeilog.getPrice();
			frompaper = imeilog.getFrompaper();
			objorgacode = imeilog.getObjorgacode();

			if (IMEI == null || IMEI.length() == 0 || orgacode == null || orgacode.length() == 0 || opercode == null || opercode.length() == 0
					|| dealpaper == null || dealpaper.length() == 0 || dealtype == null || dealtype.length() == 0)
				return false;
		}

		if (!JDBCUtil.isConnected(conn))
			return false;

		String s_sql = "INSERT INTO IMEILOG (IMEI,OrgaCode,OperCode,DealDate,DealID,DealPaper,DealType,Price,FromPaper,ObjOrgaCode) VALUES (?,?,?,SYSDATE,?,?,?,?,?,?)";
		PreparedStatement ps = conn.prepareStatement(s_sql);

		int i = 0;
		for (IMEILog imeilog : imeiloglist) {
			i++;
			IMEI = imeilog.getIMEI();
			orgacode = imeilog.getOrgacode();
			opercode = imeilog.getOpercode();
			dealid = imeilog.getDealid();
			dealpaper = imeilog.getDealpaper();
			dealtype = imeilog.getDealtype();
			price = imeilog.getPrice();
			frompaper = imeilog.getFrompaper();
			objorgacode = imeilog.getObjorgacode();

			ps.setString(1, IMEI);
			ps.setString(2, orgacode);
			ps.setString(3, opercode);
			ps.setInt(4, dealid);
			ps.setString(5, dealpaper);
			ps.setString(6, dealtype);
			ps.setDouble(7, price);
			ps.setString(8, frompaper);
			ps.setString(9, objorgacode);
			ps.addBatch();// 添加批提交
			// ps.clearParameters();// 清除参数，以提高性能
			if (i % MyConstant.JDBC_BATCH_SIZE == 0) { // 每JDBC_BATCH_SIZE条打包发送，以免内存溢出
				int result[] = ps.executeBatch();// 执行批提交
				ps.clearBatch();// 执行批提交后，必须要清除批语句，以提高性能
				for (int flag : result) {// 逐一验证提交结果是否成功
					if (flag == 0)
						return false;
				}
			}
		}
		int result[] = ps.executeBatch();// 对于未提交的，再次提交一下
		ps.clearBatch();// 执行批提交后，必须要清除批语句，以提高性能
		for (int flag : result) {// 逐一验证提交结果是否成功
			if (flag == 0)
				return false;
		}
		ps.close();
		return true;
	}

	/**
	 * 输入areaid，获取该areaid对应的电子渠道服务厅orgacode
	 * @author dyh 2009-12-15
	 * @param areaid 地市ID(只能传入1到21的数字)
	 * @return areaid对应的电子渠道服务厅orgacode，如果为null，表示无法找到
	 */
	

	/**
	 * 输入组织编码，获取该组织的渠道类型
	 * @author dyh 2009-12-15
	 * @param orgacode 组织编码
	 * @return 渠道类型，如果为null，表示无法找到该组织
	 */
	public static String getChannelTypeByOrgaCode(String orgacode) {
		if (orgacode == null || orgacode.length() == 0)
			return null;
		String result = null;
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String strSQL = "SELECT channeltype FROM ORGANIZA WHERE orgacode=?";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setString(1, orgacode);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				result = rs.getString(1);
			}
			rs.close();
			rs = null;
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			MyJDBC.close(myJDBC);
		}
	}

	/**
	 * 输入渠道类型编码，获取渠道类型中文名
	 * @author dyh 2009-12-15
	 * @param channeltype 渠道类型编码
	 * @return 渠道类型中文名
	 */
	public static String getChannelTypeName(String channeltype) {
		if (MyFormat.isStrNull(channeltype))
			return "";
		String channeltypename = "";
		if (MyConstant.CHANNEL_GMCC_RGS.equals(channeltype)) {
			channeltypename = "自有渠道+入柜商";
		} else if (MyParam.hChannelType != null && MyParam.hChannelType.size() > 0) {
			channeltypename = MyParam.hChannelType.get(channeltype);
		}
		return MyFormat.formatStr(channeltypename);
	}

	/**
	 * 输入组织编码，获取该组织的电子渠道操盘类型
	 * @author dyh 2009-12-15
	 * @param orgacode 组织编码
	 * @return 操盘类型，如果为null，表示非电子渠道或组织编码非法
	 */
	public static String getETypeByOrgaCode(String orgacode) {
		if (orgacode == null || orgacode.length() == 0)
			return null;
		String result = null;
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String strSQL = "SELECT etype FROM AREA WHERE areaid=(SELECT areaid FROM ORGANIZA WHERE orgacode=?)";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setString(1, orgacode);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				result = rs.getString(1);
			}
			rs.close();
			rs = null;
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			MyJDBC.close(myJDBC);
		}
	}

	/**
	 * 输入组织编码，获取BOSS渠道标识
	 * @author dyh 2009-12-15
	 * @param orgacode 组织编码
	 * @return BOSS渠道标识，如果为null，表示组织编码非法或非服务厅组织
	 */
	public static String getMobileOrgacodeByOrgaCode(String orgacode) {
		if (orgacode == null || orgacode.length() == 0)
			return "";
		String result = "";
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String strSQL = "SELECT mobileorgacode FROM MOBILEORGATOLOCAL WHERE orgacode=?";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setString(1, orgacode);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				result = rs.getString(1);
			}
			rs.close();
			rs = null;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyJDBC.close(myJDBC);
		}
		return result;
	}

	/**
	 * 多条IMEI插入BOSS_Depot表
	 * @author dyh 2009-12-09
	 * @param conn 将调用方法的连接传入
	 * @param imeilist List<BOSS_Depot>
	 * @return true表示插入成功，false表示失败
	 */
	public static boolean insertBOSS_Depot(Connection conn, List<BOSS_Depot> imeilist) throws Exception {
		if (imeilist == null || imeilist.size() == 0)
			return false;
		if (!JDBCUtil.isConnected(conn))
			return false;

		// 检测imeilist里每一条记录字段的合法性
		String bossid = null;
		String IMEI = null;
		String mobileorgacode = null;
		String providercode = null;
		String cityshortname = null;
		String dotype = null;// 处理类型
		for (BOSS_Depot imeiforBOSS : imeilist) {
			if (imeiforBOSS == null)
				return false;
			bossid = imeiforBOSS.getBossid();
			IMEI = imeiforBOSS.getIMEI();
			mobileorgacode = imeiforBOSS.getMobileorgacode();
			providercode = imeiforBOSS.getProvidercode();
			cityshortname = imeiforBOSS.getCityshortname();
			dotype = imeiforBOSS.getDotype();
			if (IMEI == null || IMEI.length() == 0 || bossid == null || bossid.length() == 0 || mobileorgacode == null
					|| mobileorgacode.length() == 0 || providercode == null || providercode.length() == 0 || cityshortname == null
					|| cityshortname.length() == 0 || dotype == null || dotype.length() == 0)
				return false;
		}

		String s_sql = "INSERT INTO BOSS_Depot (halldepotid,bossid,IMEI,mobileorgacode,providercode,cityshortname,DODATE,dotype) VALUES (SEQ_BossDepot.NEXTVAL,?,?,?,?,?,SYSDATE,?)";
		PreparedStatement ps = conn.prepareStatement(s_sql);

		int i = 0;
		for (BOSS_Depot imeiforBOSS : imeilist) {
			i++;
			bossid = imeiforBOSS.getBossid();
			IMEI = imeiforBOSS.getIMEI();
			mobileorgacode = imeiforBOSS.getMobileorgacode();
			providercode = imeiforBOSS.getProvidercode();
			cityshortname = imeiforBOSS.getCityshortname();
			dotype = imeiforBOSS.getDotype();

			ps.setString(1, bossid);
			ps.setString(2, IMEI);
			ps.setString(3, mobileorgacode);
			ps.setString(4, providercode);
			ps.setString(5, cityshortname);
			ps.setString(6, dotype);
			ps.addBatch();// 添加批提交
			// ps.clearParameters();// 清除参数，以提高性能
			if (i % MyConstant.JDBC_BATCH_SIZE == 0) { // 每JDBC_BATCH_SIZE条打包发送，以免内存溢出
				int result[] = ps.executeBatch();// 执行批提交
				ps.clearBatch();// 执行批提交后，必须要清除批语句，以提高性能
				for (int flag : result) {// 逐一验证提交结果是否成功
					if (flag == 0)
						return false;
				}
			}
		}
		int result[] = ps.executeBatch();// 对于未提交的，再次提交一下
		ps.clearBatch();// 执行批提交后，必须要清除批语句，以提高性能
		for (int flag : result) {// 逐一验证提交结果是否成功
			if (flag == 0)
				return false;
		}
		ps.close();
		return true;
	}

	/**
	 * 根据IMEI表记录，将多条IMEI插入BOSS_Depot表
	 * @author dyh 2011-10-08
	 * @param conn 将调用方法的连接传入
	 * @param imeilist IMEI列表
	 * @param dotype
	 * @return true表示插入成功，false表示失败
	 */
	public static boolean insertBOSS_Depot(Connection conn, ArrayList<String> imeilist, String dotype) throws Exception {
		if (imeilist == null || imeilist.size() == 0 || MyFormat.isStrNull(dotype))
			return false;
		if (!JDBCUtil.isConnected(conn))
			return false;

		StringBuilder sql = new StringBuilder();
		sql.append("INSERT INTO BOSS_Depot (halldepotid,bossid,IMEI,mobileorgacode,providercode,cityshortname,DODATE,dotype)");
		sql
				.append(" SELECT SEQ_BossDepot.NEXTVAL,colorid2bossid(colorid),imei,orgcode2bosscode(orgacode),Gd_Dyh.getCityProviderForBOSS(i.cityorgacode),ORGCODE2AREASHORTEN(orgacode),SYSDATE,? FROM IMEI WHERE IMEI=?");

		PreparedStatement ps = conn.prepareStatement(sql.toString());

		int i = 0;
		for (String IMEI : imeilist) {
			i++;
			ps.setString(1, dotype);
			ps.setString(2, IMEI);
			ps.addBatch();// 添加批提交
			// ps.clearParameters();// 清除参数，以提高性能
			if (i % MyConstant.JDBC_BATCH_SIZE == 0) { // 每JDBC_BATCH_SIZE条打包发送，以免内存溢出
				int result[] = ps.executeBatch();// 执行批提交
				ps.clearBatch();// 执行批提交后，必须要清除批语句，以提高性能
				for (int flag : result) {// 逐一验证提交结果是否成功
					if (flag == 0)
						return false;
				}
			}
		}
		int result[] = ps.executeBatch();// 对于未提交的，再次提交一下
		ps.clearBatch();// 执行批提交后，必须要清除批语句，以提高性能
		for (int flag : result) {// 逐一验证提交结果是否成功
			if (flag == 0)
				return false;
		}
		ps.close();
		return true;
	}

	/**
	 * 判断该组织是否有下级组织
	 * @author 朱家进 2010-01-04
	 * @param orgacode 当前组织orgacode
	 * @return 有true无false
	 */
	public static boolean isNextOrganizaByOrgaCode(String orgacode) {
		if (orgacode == null || orgacode.length() == 0)
			return false;
		boolean result = false;
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String strSQL = "SELECT orgacode FROM organiza WHERE parentorgacode=?";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setString(1, orgacode);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				result = true;
			}
			rs.close();
			rs = null;
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		} finally {
			MyJDBC.close(myJDBC);
		}
	}

	/**
	 * 输入areaid，判断此地市是否允许一对多供货平台
	 * @author dyh 2010-01-26
	 * @param areaid 地市ID(只能传入1到21的数字)
	 * @return true：允许一对多；false禁止一对多
	 */
	

	/**
	 * 输入orgacode，判断该组织是否允许一对多供货平台
	 * @author dyh 2010-03-23
	 * @param orgacode 组织编码
	 * @return true：允许一对多；false禁止一对多
	 */
	

	/**
	 * 查询MobileToProvider表的multiplat字段，判断该市平台是否允许一对多供货
	 * @author dyh 2010-07-26
	 * @param hall 服务厅组织编码
	 * @param cityprovider 服务厅组织编码
	 * @return true：允许一对多；false禁止一对多
	 */
	
	/**
	 * 输入用户名，判断是否有特殊权限
	 * @author dyh 2010-02-28
	 * @param usercode
	 */
	public static boolean isMe(String usercode) {
		if (usercode == null)
			return false;
		for (String u : MyConstant.CTMS_ADMIN) {
			if (usercode.indexOf(u) >= 0)
				return true;
		}
		return false;
	}

	/**
	 * 输入用户名，判断是否有权访问营销案管理权限
	 * @author dyh 2010-12-17
	 * @param usercode
	 */
	public static boolean isMarketUser(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("LINNN") >= 0 || usercode.indexOf("ZHANGYA") >= 0 || isPM(usercode) || isMe(usercode);
	}

	/**
	 * 输入用户名，判断是否为产品经理
	 * @author dyh 2011-08-19
	 * @param usercode
	 */
	public static boolean isPM(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("CHENGJING") >= 0 || usercode.indexOf("WANGGJ") >= 0 || usercode.indexOf("JIANGYI") >= 0
				|| usercode.indexOf("TANGYD") >= 0 || usercode.indexOf("DENGCG") >= 0 || isMe(usercode);
	}

	/**
	 * 输入用户名，判断是否为零星采购产品经理
	 * @author dyh 2011-08-19
	 * @param usercode
	 */
	public static boolean isSmallPM(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("PENGQR") >= 0 || usercode.indexOf("ZHENRY") >= 0 || usercode.indexOf("CHENGYL") >= 0 || isMe(usercode);
	}

	/*
	 * 输入用户名，判断是否为营销中心领导
	 * @author dyh 2011-10-01
	 * @param usercode
	 */
	public static boolean isYXLeader(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("CHUDEYAO") >= 0 || usercode.indexOf("CHUDY") >= 0 || usercode.indexOf("YUZB") >= 0 || isMe(usercode);
	}

	/*
	 * 输入用户名，判断是否为营销中心人员
	 * @author dyh 2011-10-01
	 * @param usercode
	 */
	public static boolean isYX(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("SUNML") >= 0 || usercode.indexOf("YUZB") >= 0 || isYXLeader(usercode);
	}

	/**
	 * 输入用户名，判断是否为市场部领导
	 * @author dyh 2011-10-19
	 * @param usercode
	 */
	public static boolean isSCLeader(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("LINNN") >= 0 || isMe(usercode);
	}

	/**
	 * 输入用户名，判断是否为财务领导
	 * @author dyh 2011-08-19
	 * @param usercode
	 */
	public static boolean isCWLeader(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("WANGCX") >= 0 || isMe(usercode);
	}

	/**
	 * 输入用户名，判断是否为财务人员
	 * @author dyh 2011-08-19
	 * @param usercode
	 */
	public static boolean isCW(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("LINSJ") >= 0 || usercode.indexOf("HUZB") >= 0 || isCWLeader(usercode);
	}

	/**
	 * 输入用户名，判断是否为物资部领导
	 * @author dyh 2011-08-19
	 * @param usercode
	 */
	public static boolean isWZLeader(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("YEYJ") >= 0 || isMe(usercode);
	}

	/**
	 * 输入用户名，判断是否为物资部人员
	 * @author dyh 2011-08-19
	 * @param usercode
	 */
	public static boolean isWZ(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("CHENSY") >= 0 || usercode.indexOf("WUYH") >= 0 || isWZLeader(usercode);
	}

	/**
	 * 输入用户名，判断是否为调度中心人员
	 * @author dyh 2011-08-19
	 * @param usercode
	 */
	public static boolean isDD(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("DDP3") >= 0 || isMe(usercode);
	}

	/**
	 * 输入用户名，判断是否为资金计划审批用户
	 * @author dyh 2011-08-19
	 * @param usercode
	 */
	public static boolean isFinanceAuditor(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("LINNN") >= 0 || usercode.indexOf("YEYJ") >= 0 || usercode.indexOf("CHENSY") >= 0
				|| usercode.indexOf("CHUDEYAO") >= 0 || usercode.indexOf("CHUDY") >= 0 || isMe(usercode);
	}

	/**
	 * 输入用户名，判断是否为资金计划用户
	 * @author dyh 2011-08-19
	 * @param usercode
	 */
	public static boolean isFinanceUser(String usercode) {
		if (usercode == null)
			return false;
		return isMe(usercode) || isPM(usercode) || isSmallPM(usercode) || isCW(usercode) || isWZ(usercode) || isFinanceAuditor(usercode)
				|| isYX(usercode);
	}

	/**
	 * 输入用户名，判断是否为负责RD水位设置
	 * @author dyh 2011-10-01
	 * @param usercode
	 */
	public static boolean isRDDepot(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("SUNML") >= 0 || isMe(usercode);
	}

	/**
	 * 输入用户名，判断是否为负责RD客户余额设置
	 * @author dyh 2011-10-01
	 * @param usercode
	 */
	public static boolean isRDCust(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("LINSJ") >= 0 || isMe(usercode);
	}

	/**
	 * 输入用户名，判断是否为RD相关用户
	 * @author dyh 2011-10-01
	 * @param usercode
	 */
	public static boolean isRDUser(String usercode) {
		if (usercode == null)
			return false;
		return isYX(usercode) || isCW(usercode) || isDD(usercode) || isWZ(usercode);
	}

	/**
	 * 输入用户名，判断是否有权访问集采订单修改权限
	 * @author dyh 2011-4-16
	 * @param usercode
	 */
	public static boolean isPlanUser(String usercode) {
		if (usercode == null)
			return false;
		return usercode.indexOf("DENGYB") >= 0 || usercode.indexOf("LINNN") >= 0 || usercode.indexOf("DENGCG") >= 0 || isMe(usercode);
	}

	/**
	 * 更新库存表IMEIDEPOT
	 * @author dyh 2011-09-11
	 * @param conn 事务连接
	 * @param orgacode 库存组织编码
	 * @param productid 产品编码
	 * @param amount 库存变化数量(正数为增加数量，负数为减少数量，如果相减后数量为负数，则为0)
	 * @param providerorgacode 省平台编码(orgacode为厂家时此值为null；orgacode为其他组织时此值为省平台编码)
	 * @param goodflag 是否良品
	 * @param validflag 是否在途
	 * @return 库存是否更新成功
	 */
	public static boolean updateIMEIDepot(Connection conn, String orgacode, String productid, int amount, String providerorgacode, boolean goodflag,
			boolean validflag) throws Exception {
		if (orgacode == null || productid == null)// 组织编码或产品ID不能为空
			return false;
		if (amount == 0)
			return true;
		if (!JDBCUtil.isConnected(conn))
			return false;

		int orgatypeid = getOrgaTypeID(orgacode);
		if (orgatypeid == MyConstant.INT_NULL)
			return false;
		if (MyConstant.ORGTYPE_VENDOR != orgatypeid)
			if (providerorgacode == null)// 非厂家的组织，其省平台编码必须非空
				return false;

		StringBuilder sql = new StringBuilder();
		PreparedStatement ps = null;

		// int orgid = getOrgID(orgacode);
		String s_validflag = validflag ? MyConstant.TRUE : MyConstant.FALSE;
		String s_goodflag = goodflag ? MyConstant.TRUE : MyConstant.FALSE;
		int flag = 0;
		if (amount > 0) {// 增加库存
			if (MyConstant.ORGTYPE_VENDOR == orgatypeid) {// 厂家
				sql
						.append("MERGE INTO ImeiDepot a USING (SELECT ? AS OrgaCode, ? AS ProductID,? as amount,? AS goodflag,? AS validflag FROM DUAL) b ");
				sql.append(" ON (a.OrgaCode = b.OrgaCode AND a.ProductID = b.ProductID AND a.goodflag=b.goodflag and a.validflag=b.validflag) ");
				sql.append(" WHEN MATCHED THEN UPDATE SET a.Quanitity = a.Quanitity+b.amount ");
				sql
						.append("WHEN NOT MATCHED THEN INSERT (OrgaCode,ProductID, Quanitity,goodflag,validflag) VALUES(b.OrgaCode,b.ProductID,b.amount,b.goodflag,b.validflag)");
			} else {// 非厂家
				sql
						.append("MERGE INTO ImeiDepot a USING (SELECT ? AS OrgaCode, ? AS ProductID,? as amount,? AS goodflag,? AS validflag, ? AS ProviderOrgaCode FROM DUAL) b ");
				sql
						.append(" ON (a.OrgaCode = b.OrgaCode AND a.ProductID = b.ProductID AND a.ProviderOrgaCode = b.ProviderOrgaCode AND a.goodflag=b.goodflag and a.validflag=b.validflag) ");
				sql.append(" WHEN MATCHED THEN UPDATE SET a.Quanitity = a.Quanitity+b.amount ");
				sql
						.append(" WHEN NOT MATCHED THEN INSERT (OrgaCode, ProductID, Quanitity, ProviderOrgaCode,goodflag,validflag) VALUES(b.OrgaCode,b.ProductID,b.amount,b.ProviderOrgaCode,b.goodflag,b.validflag)");
			}
		} else {// 减少库存(如果库存数量少于可减数量，则终止流程)
			amount = -amount;
			if (MyConstant.ORGTYPE_VENDOR == orgatypeid) {// 厂家
				sql
						.append("MERGE INTO ImeiDepot a USING (SELECT ? AS OrgaCode, ? AS ProductID,? as amount,? AS goodflag,? AS validflag FROM DUAL) b ");
				sql.append("ON (a.OrgaCode = b.OrgaCode AND a.ProductID = b.ProductID AND a.goodflag=b.goodflag and a.validflag=b.validflag) ");
				sql.append("WHEN MATCHED THEN UPDATE SET a.Quanitity = a.Quanitity - b.amount WHERE a.Quanitity - b.amount >= 0");
			} else {// 非厂家
				sql
						.append("MERGE INTO ImeiDepot a USING (SELECT ? AS OrgaCode, ? AS ProductID,? as amount,? AS goodflag,? AS validflag, ? AS ProviderOrgaCode FROM DUAL) b ");
				sql
						.append("ON (a.OrgaCode = b.OrgaCode AND a.ProductID = b.ProductID AND a.ProviderOrgaCode = b.ProviderOrgaCode AND a.goodflag=b.goodflag and a.validflag=b.validflag) ");
				sql.append("WHEN MATCHED THEN UPDATE SET a.Quanitity = a.Quanitity - b.amount WHERE a.Quanitity - b.amount >= 0");
			}
		}
		ps = conn.prepareStatement(sql.toString());
		ps.setString(1, orgacode);
		ps.setString(2, productid);
		ps.setInt(3, amount);
		ps.setString(4, s_goodflag);
		ps.setString(5, s_validflag);
		if (MyConstant.ORGTYPE_VENDOR != orgatypeid) {// 非厂家
			ps.setString(6, providerorgacode);
		}
		flag = ps.executeUpdate();
		ps.close();
		ps = null;
		return flag == 1;
	}

	/**
	 * 发货操作：更新库存表IMEIDEPOT:锁定发货IMEI数量
	 * @author dyh 2011-09-11
	 * @param conn 事务连接
	 * @param orgacode 库存组织编码
	 * @param productid 产品编码
	 * @param fhamount 发货数量
	 * @param providerorgacode 省平台编码(orgacode为厂家时此值为null；orgacode为其他组织时此值为省平台编码)
	 * @param goodflag 是否良品
	 * @param depotid 仓位
	 * @return 库存是否更新成功
	 */
	public static boolean updateIMEIDepotFH(Connection conn, String orgacode, String productid, int fhamount, String providerorgacode,
			boolean goodflag) throws Exception {
		// 减去可用库存
		boolean ok = updateIMEIDepot(conn, orgacode, productid, -fhamount, providerorgacode, goodflag, true);

		// 增加在途库存
		if (ok)
			ok = updateIMEIDepot(conn, orgacode, productid, fhamount, providerorgacode, goodflag, false);

		return ok;
	}

	/**
	 * 发货撤销操作：更新库存表IMEIDEPOT:取消发货IMEI数量
	 * @author dyh 2011-09-11
	 * @param conn 事务连接
	 * @param orgacode 库存组织编码
	 * @param productid 产品编码
	 * @param fhamount 发货数量
	 * @param providerorgacode 省平台编码(orgacode为厂家时此值为null；orgacode为其他组织时此值为省平台编码)
	 * @param goodflag 是否良品
	 * @param depotid 仓位
	 * @return 库存是否更新成功
	 */
	public static boolean updateIMEIDepotFHCancel(Connection conn, String orgacode, String productid, int fhamount, String providerorgacode,
			boolean goodflag) throws Exception {
		// 增加可用库存
		boolean ok = updateIMEIDepot(conn, orgacode, productid, fhamount, providerorgacode, goodflag, true);

		// 减少在途库存
		if (ok)
			ok = updateIMEIDepot(conn, orgacode, productid, -fhamount, providerorgacode, goodflag, false);

		return ok;
	}

	/**
	 * 输入配送周期值，输出配送周期名称
	 * @author dyh 2010-04-15
	 * @param minute 配送时限值
	 * @return 配送时限名称
	 */
	

	/**
	 * 输入配送周期值，输出配送周期名称
	 * @author dyh 2010-04-15
	 * @param minute 配送时限值
	 * @return 配送时限名称
	 */

	/**
	 * 输入价格，输出价格段名称
	 * @author dyh 2010-04-15
	 * @param price 价格
	 * @return 价格段名称
	 */
	
	/**
	 * 输入价格，输出价格段名称
	 * @author dyh 2010-04-15
	 * @param price 价格
	 * @return 价格段名称
	 */
	public static String getPriceParagraphName(Double price) {
		return getPriceParagraphName(price.doubleValue());
	}

	/**
	 * 输入SEQUENCE名称，获取SEQ值
	 * @author dyh 2010-06-15
	 * @param SEQname SEQUENCE名称
	 * @return SEQ.NextVal 如果异常，则返回-1
	 */
	public static int getSEQ(String SEQname) {
		int SEQvalue = -1;
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			SEQvalue = getSEQ(myJDBC.getConnection(), SEQname);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyJDBC.close(myJDBC);
		}
		return SEQvalue;
	}

	/**
	 * 输入SEQUENCE名称，获取SEQ值
	 * @author dyh 2010-10-28
	 * @param conn 连接
	 * @param SEQname SEQUENCE名称
	 * @return SEQ.NextVal 如果异常，则返回-1
	 */
	public static int getSEQ(Connection conn, String SEQname) {
		int SEQvalue = -1;
		if (SEQname != null && SEQname.length() > 0) {
			try {
				if (!JDBCUtil.isConnected(conn)) {
					return SEQvalue;
				}
				String strSQL = "SELECT " + SEQname + ".NEXTVAL FROM DUAL";
				PreparedStatement ps = conn.prepareStatement(strSQL);
				ResultSet rs = ps.executeQuery();
				if (rs.next()) {
					SEQvalue = rs.getInt(1);
				}
				rs.close();
				ps.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
			}
		}
		return SEQvalue;
	}

	/**
	 * 输入城市类别ID，输出城市类别名称
	 * @author dyh 2010-07-14
	 * @param rank 城市类别ID
	 * @return 城市类别名称
	 */
	public static String getCityTypeName(int rank) {
		String citytypename = "";
		try {
			if (MyParam.hCityType != null) {
				citytypename = MyParam.hCityType.get(Integer.valueOf(rank));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return citytypename == null ? "" : citytypename;
	}

	/**
	 * 输入用户编码，获取用户名
	 * @author dyh 2010-07-13
	 * @param opercode 用户编码
	 * @return 用户名
	 */
	public static String getOperName(String opercode) {
		String opername = "";
		if (!MyFormat.isStrNull(opercode)) {
			if ("OA".equals(opercode) || "PSGM".equals(opercode) || "CTMS".equals(opercode)) {
				opername = opercode;
			} else {
				MyJDBC myJDBC = null;
				try {
					myJDBC = new MyJDBC();
					String strSQL = "SELECT opername FROM OPERS WHERE opercode=?";
					PreparedStatement ps = myJDBC.prepareStatement(strSQL);
					ps.setString(1, opercode);
					ResultSet rs = ps.executeQuery();
					if (rs.next()) {
						opername = rs.getString(1);
					}
					rs.close();
					rs = null;
				} catch (Exception e) {
					e.printStackTrace();
				} finally {
					MyJDBC.close(myJDBC);
				}
			}
		}
		return MyFormat.formatStr(opername);
	}

	/**
	 * 输入用户ID，获取用户名
	 * @author dyh 2010-12-30
	 * @param operid 用户ID
	 * @return 用户名
	 */
	public static String getOperName(int operid) {
		String opername = "";
		if (operid > 0) {
			MyJDBC myJDBC = null;
			try {
				myJDBC = new MyJDBC();
				String strSQL = "SELECT opername FROM OPERS WHERE operid=?";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setInt(1, operid);
				ResultSet rs = ps.executeQuery();
				if (rs.next()) {
					opername = rs.getString(1);
				}
				rs.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return MyFormat.formatStr(opername);
	}

	/**
	 * 输入用户ID，获取用户编码
	 * @author dyh 2010-12-30
	 * @param operid 用户ID
	 * @return 用户编码
	 */
	public static String getOperCode(int operid) {
		String opercode = "";
		if (operid > 0) {
			MyJDBC myJDBC = null;
			try {
				myJDBC = new MyJDBC();
				String strSQL = "SELECT opercode FROM OPERS WHERE operid=?";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setInt(1, operid);
				ResultSet rs = ps.executeQuery();
				if (rs.next()) {
					opercode = rs.getString(1);
				}
				rs.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return MyFormat.formatStr(opercode);
	}

	/**
	 * 获取市平台供货属性
	 * @author dyh 2010-07-24
	 * @param hallcode 服务厅编码
	 * @param cityProvider 市平台组织编码
	 * @return 市平台供货属性1-供应全系列；2-只供应用2G；3-只供应3G；MyConstant.SELECT_FIRST_VALUE表示数据有误
	 */
	public static String getCityProviderType(String hallcode, String cityProvider) {
		String cityProviderType = MyConstant.SELECT_FIRST_VALUE;
		if (MyFormat.isStrNull(cityProvider) || MyFormat.isStrNull(hallcode))
			return cityProviderType;
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String strSQL = "";
			strSQL = "SELECT cityprovidertype FROM MOBILETOPROVIDER WHERE mobileorgacode=? AND cityproviderorgacode=? ";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setString(1, hallcode);
			ps.setString(2, cityProvider);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				cityProviderType = rs.getString(1);
			}
			rs.close();
			rs = null;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyJDBC.close(myJDBC);
		}
		return cityProviderType;
	}

	/**
	 * 输入品牌分档，输出品牌分档名称
	 * @author dyh 2010-08-13
	 * @param brandlevel 品牌分档
	 * @return 品牌分档名称
	 */
	

	/**
	 * 输入品牌分档，输出品牌分档名称
	 * @author dyh 2010-08-13
	 * @param brandlevel 品牌分档
	 * @return 品牌分档名称
	 */
	

	/**
	 * 输入产品ID和组织编码，输出该组织所有该产品的库存数量
	 * @author dyh 2010-9-9
	 * @param productid
	 * @param orgacode
	 * @return
	 */
	public static int getIMEIDepot(String productid, String orgacode) {
		int depot = 0;
		if (!MyFormat.isStrNull(productid) && !MyFormat.isStrNull(orgacode)) {
			MyJDBC myJDBC = null;
			try {
				myJDBC = new MyJDBC();
				String strSQL = "SELECT sum(quanitity) FROM IMEIDEPOT WHERE productid=? AND orgacode=?";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, productid);
				ps.setString(2, orgacode);
				ResultSet rs = ps.executeQuery();
				if (rs.next()) {
					depot = rs.getInt(1);
				}
				rs.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return depot;
	}

	/**
	 * 输入产品ID、组织编码和供货平台编码，输出该组织由此供货平台供货的该产品的库存数量
	 * @author dyh 2010-9-9
	 * @param productid
	 * @param orgacode
	 * @param provider 省平台编码
	 * @return
	 */
	public static int getIMEIDepot(String productid, String orgacode, String provider) {
		int depot = 0;
		if (!MyFormat.isStrNull(productid) && !MyFormat.isStrNull(orgacode) && !MyFormat.isStrNull(provider)) {
			MyJDBC myJDBC = null;
			try {
				myJDBC = new MyJDBC();
				String strSQL = "SELECT sum(quanitity) FROM IMEIDEPOT WHERE productid=? AND orgacode=? AND providerorgacode=?";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, productid);
				ps.setString(2, orgacode);
				ps.setString(3, provider);
				ResultSet rs = ps.executeQuery();
				if (rs.next()) {
					depot = rs.getInt(1);
				}
				rs.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return depot;
	}

	/**
	 * 输入产品ID和地市ID，输出该地市所有服务厅该产品的库存数量
	 * @author dyh 2010-9-9
	 * @param productid
	 * @param areaid
	 * @return
	 */
	public static int getIMEIDepot(String productid, int areaid) {
		int depot = 0;
		if (!MyFormat.isStrNull(productid) && MyFormat.checkAreaID(areaid)) {
			MyJDBC myJDBC = null;
			try {
				myJDBC = new MyJDBC();
				String strSQL = "SELECT sum(i.quanitity) FROM IMEIDEPOT i,ORGANIZA o WHERE i.productid=? AND i.orgacode=o.orgacode AND o.orgatypeid=? AND o.areaid=?";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, productid);
				ps.setInt(2, MyConstant.ORGTYPE_HALL);
				ps.setInt(3, areaid);
				ResultSet rs = ps.executeQuery();
				if (rs.next()) {
					depot = rs.getInt(1);
				}
				rs.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return depot;
	}

	/**
	 * 输入市平台编码，输出经规格化后市平台编码(如果是市级社会渠道，则返回MyConstant.SOCIAL_CITY_PROVIDER[])。本方法只适用于BOSS_DEPOT表的providercode字段
	 * @author dyh 2010-9-20
	 * @param cityprovider
	 * @return 经规格化后市平台编码(如果是市级社会渠道，则返回MyConstant.SOCIAL_CITY_PROVIDER[])；如果异常，则返回null
	 */
	public static String getCityProviderForBOSS(String cityprovider) {
		String cityproviderOK = null;
		if (!MyFormat.isStrNull(cityprovider)) {
			String channeltype = getChannelTypeByOrgaCode(cityprovider);
			if (!MyFormat.isStrNull(channeltype)) {
				if (MyConstant.CHANNEL_SOCIAL_CITY.equals(channeltype)) {
					int areaid = MyParamUtil.getOrgaAreaID(cityprovider);
					cityproviderOK = MyConstant.SOCIAL_CITY_PROVIDER[areaid];
				} else if (MyConstant.CHANNEL_RD.equals(channeltype)) {
					int areaid = MyParamUtil.getOrgaAreaID(cityprovider);
					cityproviderOK = MyConstant.RD_CITY_PROVIDER[areaid];
				} else
					cityproviderOK = cityprovider;
			}
		}
		return cityproviderOK;
	}

	/**
	 * 根据服务厅编码和产品ID，输出服务厅供货平台编码(非一对多平台,multiplat='0')
	 * @author dyh 2010-10-20
	 * @param hallcode
	 * @param productid
	 * @return 服务厅供货平台编码(非一对多平台,multiplat='0')
	 */
	public static String getCityProvider(String hallcode, String productid) {
		String cityprovider = "";
		if (!MyFormat.isStrNull(hallcode) && !MyFormat.isStrNull(productid)) {
			MyJDBC myJDBC = null;
			try {
				myJDBC = new MyJDBC();
				String strSQL = "";
				strSQL = "SELECT cityproviderorgacode FROM MOBILETOPROVIDER WHERE multiplat='0' AND mobileorgacode=? AND (cityprovidertype='1' OR cityprovidertype IN (SELECT productsystem FROM productgroup WHERE productid=?)) ";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, hallcode);
				ps.setString(2, productid);
				ResultSet rs = ps.executeQuery();
				if (rs.next()) {
					cityprovider = rs.getString(1);
				}
				rs.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return cityprovider;
	}

	/**
	 * 根据服务厅编码，输出相同渠道类型的供货平台编码(非一对多平台,multiplat='0')
	 * @author dyh 2011-10-5
	 * @param hallcode
	 * @param channeltype
	 * @return
	 */
	public static String getCityProviderInSameChanneltype(String hallcode, String channeltype) {
		String cityprovider = "";
		if (!MyFormat.isStrNull(hallcode)) {
			MyJDBC myJDBC = null;
			try {
				myJDBC = new MyJDBC();
				String strSQL = "";
				strSQL = "SELECT cityproviderorgacode FROM MOBILETOPROVIDER m WHERE multiplat='0' AND mobileorgacode=? AND EXISTS(SELECT 1 FROM ORGANIZA h WHERE h.orgacode=m.cityproviderorgacode AND h.channeltype=?) ORDER BY cityproviderorgacode";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, hallcode);
				ps.setString(2, channeltype);
				ResultSet rs = ps.executeQuery();
				if (rs.next()) {
					cityprovider = rs.getString(1);
				}
				rs.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return cityprovider;
	}

	/**
	 * 根据省平台编码，获取市平台列表
	 * @author dyh 2011-10-5
	 * @param provprovider
	 * @return 市平台列表<code,shortname>
	 */
	public static Map<String, String> getCityProviderList(String provprovider) {
		Map<String, String> cityprovider = null;
		if (!MyFormat.isStrNull(provprovider)) {
			MyJDBC myJDBC = null;
			try {
				myJDBC = new MyJDBC();
				String strSQL = "";
				strSQL = "SELECT orgacode,shortname FROM ORGANIZA WHERE parentorgacode=? AND orgatypeid=6 AND status='1' ORDER BY areaid";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, provprovider);
				ResultSet rs = ps.executeQuery();
				cityprovider = new LinkedHashMap<String, String>();
				while (rs.next()) {
					cityprovider.put(rs.getString(1), rs.getString(2));
				}
				rs.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return cityprovider;
	}

	/**
	 * 根据渠道类型：自有渠道称为平台，其他称为仓
	 * @author dyh 2011-10-5
	 * @param channeltype
	 * @return
	 */
	public static String getProviderTip(String channeltype) {
		return MyConstant.CHANNEL_GMCC.equals(channeltype) ? "平台" : "仓";
	}

	/**
	 * 根据渠道类型：自有渠道称为服务厅，其他称为网点
	 * @author dyh 2011-10-5
	 * @param channeltype
	 * @return
	 */
	public static String getHallTip(String channeltype) {
		return MyConstant.CHANNEL_GMCC.equals(channeltype) ? "服务厅" : "网点";
	}

	/**
	 * 输入集团反馈代码，输出集团反馈代码名称
	 * @author dyh 2010-11-05
	 * @param feedbackcode 集团反馈代码
	 * @return 集团反馈代码名称
	 */


	/**
	 * 获取电子渠道补货类型名称
	 * @author dyh 2010-11-16
	 * @param reqtype 电子渠道补货类型ID
	 * @return 电子渠道补货类型名称
	 */
	
	/**
	 * 修改用户密码
	 * @author dyh 2010-12-05
	 * @param opercode 用户名
	 * @param newpasswd 新密码(未经过MD5加密)
	 * @return 修改是否成功
	 */
	public static boolean changeOperPasswd(String opercode, String newpasswd) {
		return changeOperPasswd(opercode, newpasswd, opercode);
	}

	/**
	 * 修改用户密码
	 * @author dyh 2010-12-05
	 * @param opercode 用户名
	 * @param newpasswd 新密码(未经过MD5加密)
	 * @param changeopercode 操作本次修改动作的用户(如果为null，表示为本人修改自己的密码)
	 * @return 修改是否成功
	 */
	public static boolean changeOperPasswd(String opercode, String newpasswd, String changeopercode) {
		boolean ok = false;
		if (MyFormat.isStrNull(opercode) || MyFormat.isStrNull(newpasswd))
			return ok;
		if (MyFormat.isStrNull(changeopercode))
			changeopercode = opercode;
		MyJDBC myJDBC = null;
		try {
			int flag = 0;
			myJDBC = new MyJDBC();
			myJDBC.beginTransaction();
			String MD5_newPasswd = MyCode.MD5(newpasswd);
			String sql = "INSERT INTO USERPASSWDCHANGE (opercode,passwdold,passwdnew,changedate,changeopercode) SELECT ?,passwd,?,SYSDATE,? FROM OPERS WHERE opercode=?";
			PreparedStatement ps = myJDBC.prepareStatement(sql);
			ps.setString(1, opercode);
			ps.setString(2, MD5_newPasswd);
			ps.setString(3, changeopercode);
			ps.setString(4, opercode);
			flag = ps.executeUpdate();
			if (flag == 1) {
				sql = "UPDATE OPERS SET passwd=? WHERE opercode=?";
				ps = myJDBC.prepareStatement(sql);
				ps.setString(1, MD5_newPasswd);
				ps.setString(2, opercode);
				flag = ps.executeUpdate();
				ok = (flag == 1);
			}
			if (ok)
				myJDBC.commitTransaction();
			else
				myJDBC.rollbackTransaction();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyJDBC.close(myJDBC);
		}
		return ok;
	}

	/**
	 * 获取地市目标
	 * @author dyh 2011-1-18
	 * @param year
	 * @param areaid
	 * @param targettype
	 * @return
	 */
	public static int getSaleTarget(String year, int areaid, String targettype) throws Exception {
		int amount = 0;
		if (!MyFormat.isStrNull(year) && !MyFormat.isStrNull(targettype)) {
			MyJDBC myJDBC = null;
			try {
				myJDBC = new MyJDBC();
				String strSQL = "";
				strSQL = "SELECT amount FROM AREATARGET WHERE targetyear=? AND areaid=? AND targettype=? ";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, year);
				ps.setInt(2, areaid);
				ps.setString(3, targettype);
				ResultSet rs = ps.executeQuery();
				if (rs.next()) {
					amount = rs.getInt(1);
				}
				rs.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return amount;
	}

	public static Map<String, Integer> outputSortedHashMap(HashMap<String, Integer> map) {
		Map<String, Integer> tempMap = new LinkedHashMap<String, Integer>();
		List<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(map.entrySet());
		Collections.sort(list, new EntryComparator());
		Iterator<Map.Entry<String, Integer>> i = list.iterator();
		while (i.hasNext()) {
			Map.Entry<String, Integer> entry = i.next();
			tempMap.put(entry.getKey(), entry.getValue());
		}
		return tempMap;
	}

	/**
	 * 获取省平台信息
	 * @author youcl 2011-2-9
	 */
	public static Map<String, String> getProv() {
		Map<String, String> provMap = new LinkedHashMap<String, String>();
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String strSQL = "SELECT orgid,shortname FROM organiza WHERE Status=? and orgatypeid=? and channeltype in (?,?,?) ORDER BY channeltype";
			PreparedStatement ps = myJDBC.prepareStatement(strSQL);
			ps.setString(1, MyConstant.TRUE);
			ps.setInt(2, MyConstant.ORGTYPE_PROVPROVIDER);
			ps.setString(3, MyConstant.CHANNEL_GMCC);
			ps.setString(4, MyConstant.CHANNEL_RGS);
			ps.setString(5, MyConstant.CHANNEL_SOCIAL_PROV);
			ResultSet rs = ps.executeQuery();
			while (rs.next()) {
				provMap.put(rs.getString(1), rs.getString(2));
			}
			rs.close();
			ps.close();
			rs = null;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyJDBC.close(myJDBC);
		}
		return provMap;
	}

	/**
	 * 获取指定渠道类型的省平台信息
	 * @author youcl 2011-4-18
	 * @param channeltype
	 * @return
	 */
	public static Map<String, String> getProv(String channeltype) {
		Map<String, String> provMap = new LinkedHashMap<String, String>();
		MyJDBC myJDBC = null;
		if (!MyFormat.isStrNull(channeltype)) {
			try {
				myJDBC = new MyJDBC();
				String strSQL = "SELECT orgid,shortname FROM organiza WHERE Status=? and orgatypeid=? and channeltype =? ORDER BY orgid";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, MyConstant.TRUE);
				ps.setInt(2, MyConstant.ORGTYPE_PROVPROVIDER);
				ps.setString(3, channeltype);
				ResultSet rs = ps.executeQuery();
				while (rs.next()) {
					provMap.put(rs.getString(1), rs.getString(2));
				}
				rs.close();
				ps.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return provMap;
	}

	/**
	 * 获取地市下属分区
	 * @author dyh 2011-5-15
	 * @param areaid
	 * @return Map<orgid,shortname>
	 */
	public static Map<Integer, String> getCountyList(int areaid) {
		Map<Integer, String> orgMap = null;
		MyJDBC myJDBC = null;
		if (MyFormat.checkAreaID(areaid)) {
			try {
				orgMap = new LinkedHashMap<Integer, String>();
				myJDBC = new MyJDBC();
				String strSQL = "SELECT orgid,shortname FROM organiza WHERE Status=? and orgatypeid=? and areaid =? ORDER BY shortname";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, MyConstant.TRUE);
				ps.setInt(2, MyConstant.ORGTYPE_COUNTYMOBILE);
				ps.setInt(3, areaid);
				ResultSet rs = ps.executeQuery();
				while (rs.next()) {
					orgMap.put(rs.getInt(1), rs.getString(2));
				}
				rs.close();
				ps.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return orgMap;
	}

	/**
	 * 获取区/县下相应渠道类型的服务厅
	 * @author dyh 2011-5-15
	 * @param countyorgid 区/县组织ID
	 * @param channeltype 渠道类型(如果为空或-1，表示全部渠道类型)
	 * @return Map<orgacode,shortname>
	 */
	public static Map<String, String> getHallListInCounty(int countyorgid, String channeltype) {
		Map<String, String> orgMap = null;
		MyJDBC myJDBC = null;
		if (countyorgid > 0) {
			try {
				orgMap = new LinkedHashMap<String, String>();
				myJDBC = new MyJDBC();
				StringBuilder sql = new StringBuilder();
				sql.append("SELECT orgacode,shortname FROM organiza WHERE status=? and orgatypeid=? and parentorgid =?");
				if (!MyFormat.isStrNull(channeltype) && !MyConstant.SELECT_FIRST_VALUE.equals(channeltype)) {
					sql.append(" AND channeltype=?");
				}
				sql.append(" ORDER BY shortname");
				PreparedStatement ps = myJDBC.prepareStatement(sql);
				ps.setString(1, MyConstant.TRUE);
				ps.setInt(2, MyConstant.ORGTYPE_HALL);
				ps.setInt(3, countyorgid);
				if (!MyFormat.isStrNull(channeltype) && !MyConstant.SELECT_FIRST_VALUE.equals(channeltype)) {
					ps.setString(4, channeltype);
				}
				ResultSet rs = ps.executeQuery();
				while (rs.next()) {
					orgMap.put(rs.getString(1), rs.getString(2));
				}
				rs.close();
				ps.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return orgMap;
	}

	/**
	 * 获取地市相应渠道类型的市平台
	 * @author dyh 2011-5-15
	 * @param areaid 地市ID
	 * @param channeltype 渠道类型(如果为空或-1，表示全部渠道类型)
	 * @return Map<市平台编码,省平台名称>
	 */
	public static Map<String, String> getCityProviderList(int areaid, String channeltype) {
		Map<String, String> orgMap = null;
		MyJDBC myJDBC = null;
		if (MyFormat.checkAreaID(areaid)) {
			try {
				orgMap = new LinkedHashMap<String, String>();
				myJDBC = new MyJDBC();
				StringBuilder sql = new StringBuilder();
				sql
						.append("SELECT c.orgacode,p.shortname FROM organiza c,organiza p WHERE p.orgid=c.parentorgid AND p.status=? AND c.status=? and c.orgatypeid=? and c.areaid =? AND c.multiplat='0'");
				if (!MyFormat.isStrNull(channeltype) && !MyConstant.SELECT_FIRST_VALUE.equals(channeltype)) {
					sql.append(" AND c.channeltype=?");
				}
				sql.append(" ORDER BY p.shortname");
				PreparedStatement ps = myJDBC.prepareStatement(sql);
				ps.setString(1, MyConstant.TRUE);
				ps.setString(2, MyConstant.TRUE);
				ps.setInt(3, MyConstant.ORGTYPE_CITYPROVIDER);
				ps.setInt(4, areaid);
				if (!MyFormat.isStrNull(channeltype) && !MyConstant.SELECT_FIRST_VALUE.equals(channeltype)) {
					ps.setString(5, channeltype);
				}
				ResultSet rs = ps.executeQuery();
				while (rs.next()) {
					orgMap.put(rs.getString(1), rs.getString(2));
				}
				rs.close();
				ps.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return orgMap;
	}

	/**
	 * 获取服务厅对应的供货平台
	 * @author dyh 2011-5-15
	 * @param hallorgcode
	 * @return Map<供货平台类型,市平台编码>
	 */
	public static Map<String, String> getCityProviderByHall(String hallorgcode) {
		Map<String, String> orgMap = null;
		MyJDBC myJDBC = null;
		if (!MyFormat.isStrNull(hallorgcode)) {
			try {
				orgMap = new HashMap<String, String>();
				myJDBC = new MyJDBC();
				String strSQL = "SELECT cityprovidertype,cityproviderorgacode FROM MOBILETOPROVIDER WHERE status=? and mobileorgacode=? and multiplat='0'";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, MyConstant.TRUE);
				ps.setString(2, hallorgcode);
				ResultSet rs = ps.executeQuery();
				while (rs.next()) {
					orgMap.put(rs.getString(1), rs.getString(2));
				}
				rs.close();
				ps.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return orgMap;
	}

	/**
	 * 获取服务厅对应的供货省平台
	 * @author dyh 2011-9-17
	 * @param hallorgcode
	 * @return Map<省平台编码,省平台名称>
	 */
	public static Map<String, String> getProviderByHall(String hall) {
		Map<String, String> orgMap = null;
		MyJDBC myJDBC = null;
		if (!MyFormat.isStrNull(hall)) {
			try {
				orgMap = new HashMap<String, String>();
				myJDBC = new MyJDBC();
				String strSQL = "SELECT orgacode,shortname FROM organiza WHERE orgacode IN (SELECT providerorgacode FROM mobiletoprovider WHERE mobileorgacode=?) ORDER BY shortname";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, hall);
				ResultSet rs = ps.executeQuery();
				while (rs.next()) {
					orgMap.put(rs.getString(1), rs.getString(2));
				}
				rs.close();
				ps.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return orgMap;
	}

	/**
	 * 获取服务厅库存对应的供货省平台
	 * @author dyh 2011-9-17
	 * @param hallorgcode
	 * @return Map<省平台编码,省平台名称>
	 */
	public static Map<String, String> getDepotProviderByHall(String hall) {
		Map<String, String> orgMap = null;
		MyJDBC myJDBC = null;
		if (!MyFormat.isStrNull(hall)) {
			try {
				orgMap = new HashMap<String, String>();
				myJDBC = new MyJDBC();
				String strSQL = "SELECT orgacode,shortname FROM organiza o WHERE EXISTS(SELECT 1 FROM MOBILETOPROVIDER m WHERE m.providerorgacode=o.orgacode AND m.mobileorgacode=?) ORDER BY shortname";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setString(1, hall);
				ResultSet rs = ps.executeQuery();
				while (rs.next()) {
					orgMap.put(rs.getString(1), rs.getString(2));
				}
				rs.close();
				ps.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return orgMap;
	}

	/**
	 * 根据地市ID和省平台，获取市平台
	 * @author dyh 2011-10-17
	 * @param areaid
	 * @param provprovider
	 * @return 市平台编码
	 */
	public static String getCityProvider(int areaid, String provprovider) {
		String cityprovider = "";
		MyJDBC myJDBC = null;
		if (!MyFormat.isStrNull(provprovider) && MyFormat.checkAreaID(areaid)) {
			try {
				myJDBC = new MyJDBC();
				String strSQL = "SELECT orgacode FROM organiza WHERE areaid=? AND parentorgacode=?";
				PreparedStatement ps = myJDBC.prepareStatement(strSQL);
				ps.setInt(1, areaid);
				ps.setString(2, provprovider);
				ResultSet rs = ps.executeQuery();
				if (rs.next()) {
					cityprovider = rs.getString(1);
				}
				rs.close();
				ps.close();
				rs = null;
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				MyJDBC.close(myJDBC);
			}
		}
		return cityprovider;
	}

	/**
	 * 获取审批状态名称
	 * @author dyh 2011-10-20
	 * @param status
	 * @return
	 */


}